package com.itheima.string;
//用户登录
import java.util.Scanner;

public class Test01 {
    public static void main(String[] args) {
        for (int i = 1; i <= 3; i++) {
            String username = "admin";
            String password = "996007";
            Scanner sc = new Scanner(System.in);
            System.out.println("请输入用户名");
            String scUsername = sc.nextLine();
            System.out.println("请输入密码");
            String scPassword = sc.nextLine();
            if (username.equals(scUsername) && password.equals(scPassword)) {
                System.out.println("登陆成功");
                break;
            } else if (i == 3) {
                System.out.println("您的输入次数已达上限,请明天再试");//效验失败,返回
                break;
            } else {
                System.out.println("您还有" + (3 - i) + "次机会!,请重新新输入");
            }

        }
    }

}
